package com.mc.string;

import java.util.Scanner;

public class ToDecimal {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        while(sc.hasNext()){
            String input = sc.nextLine();
            input = input.substring(2);
            int sum=0;
            for(int i=0;i<input.length();i++){
            	int temp = trans(input.charAt(i));
            	sum = (sum<<4)|temp;
            }
            System.out.println(sum);
        }
    }
    public static int trans(char ch){
        if(ch>='0'&&ch<='9')
            return ch-'0';
        switch(ch){
            case 'A':return 10;
            case 'B':return 11;
            case 'C':return 12;
            case 'D':return 13;
            case 'E':return 14;
            case 'F':return 15;
        }
        return -1;
    }
}
